package vn.edu.saigontech.ncms.model.program;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.OptimisticLockType;

import vn.edu.saigontech.ncms.model.BaseEntity;
import vn.edu.saigontech.ncms.model.result.GradeDetail;

@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true, optimisticLock = OptimisticLockType.ALL)
@Table(name = "ncms_program")
@SuppressWarnings("serial")
public class Program extends BaseEntity {

	@Column(name = "name", unique = true, nullable = false)
	private String name;
	
	@Column(name = "notation")
	private String notation;
	
	@Column(name = "report_order")
	private int reportOrder;

	@Column(name = "active")
	private boolean active;

	@Column(name = "sequence")
	private int order;

	@Enumerated
	@Column(name = "program_type")
	private ProgramType programType;
	
	@OneToOne
	@JoinColumn(name = "midterm_grade_detail_id")
	private GradeDetail midtermGradeDetail;
	
	@OneToOne
	@JoinColumn(name = "final_grade_detail_id")
	private GradeDetail finalGradeDetail;
	
	@OneToOne
	@JoinColumn(name = "cambridge_grade_detail_id")
	private GradeDetail cambridgeGradeDetail;

	@Column(name = "comment", length = 4000)
	private String comment;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "program")
	@OrderBy("order asc")
	private Set<Level> levels = new HashSet<Level>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<Level> getLevels() {
		return levels;
	}

	public void setLevels(Set<Level> levels) {
		this.levels = levels;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public ProgramType getProgramType() {
		return programType;
	}

	public void setProgramType(ProgramType programType) {
		this.programType = programType;
	}

	public GradeDetail getMidtermGradeDetail() {
		return midtermGradeDetail;
	}

	public void setMidtermGradeDetail(GradeDetail midtermGradeDetail) {
		this.midtermGradeDetail = midtermGradeDetail;
	}

	public GradeDetail getFinalGradeDetail() {
		return finalGradeDetail;
	}

	public void setFinalGradeDetail(GradeDetail finalGradeDetail) {
		this.finalGradeDetail = finalGradeDetail;
	}

	public GradeDetail getCambridgeGradeDetail() {
		return cambridgeGradeDetail;
	}

	public void setCambridgeGradeDetail(GradeDetail cambridgeGradeDetail) {
		this.cambridgeGradeDetail = cambridgeGradeDetail;
	}

	public String getNotation() {
		return notation;
	}

	public void setNotation(String notation) {
		this.notation = notation;
	}

	public int getReportOrder() {
		return reportOrder;
	}

	public void setReportOrder(int reportOrder) {
		this.reportOrder = reportOrder;
	}
}